package com.ruoyi.api.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.api.domain.InterfaceInfo;
import com.ruoyi.api.service.IInterfaceInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 开放接口信息Controller
 * 
 * @author zcj
 * @date 2024-07-14
 */
@Api("接口信息")
@RestController
@RequestMapping("/api/interfaceInfo")
public class InterfaceInfoController extends BaseController
{
    @Autowired
    private IInterfaceInfoService interfaceInfoService;

    /**
     * 查询开放接口信息列表
     */
    @PreAuthorize("@ss.hasPermi('api:interfaceInfo:list')")
    @GetMapping("/list")
    @ApiOperation("查询开放接口信息列表")
    public TableDataInfo list(InterfaceInfo interfaceInfo)
    {
        startPage();
        List<InterfaceInfo> list = interfaceInfoService.selectInterfaceInfoList(interfaceInfo);
        return getDataTable(list);
    }

    /**
     * 导出开放接口信息列表
     */
    @PreAuthorize("@ss.hasPermi('api:interfaceInfo:export')")
    @Log(title = "开放接口信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InterfaceInfo interfaceInfo)
    {
        List<InterfaceInfo> list = interfaceInfoService.selectInterfaceInfoList(interfaceInfo);
        ExcelUtil<InterfaceInfo> util = new ExcelUtil<InterfaceInfo>(InterfaceInfo.class);
        util.exportExcel(response, list, "开放接口信息数据");
    }

    /**
     * 获取开放接口信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('api:interfaceInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(interfaceInfoService.selectInterfaceInfoById(id));
    }

    /**
     * 新增开放接口信息
     */
    @PreAuthorize("@ss.hasPermi('api:interfaceInfo:add')")
    @Log(title = "开放接口信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InterfaceInfo interfaceInfo)
    {
        return toAjax(interfaceInfoService.insertInterfaceInfo(interfaceInfo));
    }

    /**
     * 修改开放接口信息
     */
    @PreAuthorize("@ss.hasPermi('api:interfaceInfo:edit')")
    @Log(title = "开放接口信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InterfaceInfo interfaceInfo)
    {
        return toAjax(interfaceInfoService.updateInterfaceInfo(interfaceInfo));
    }

    /**
     * 删除开放接口信息
     */
    @PreAuthorize("@ss.hasPermi('api:interfaceInfo:remove')")
    @Log(title = "开放接口信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(interfaceInfoService.deleteInterfaceInfoByIds(ids));
    }
}
